package com.boyue.test;

import com.boyue.dao.AddressListDao;
import com.boyue.dao.DatabaseUtil;
import com.boyue.dao.impl.AddressListDaoImpl;
import com.boyue.entity.AddressList;
import com.boyue.utils.PageInfo;

import java.sql.SQLException;

/**
 * @auth wzy
 * @date 2023/9/1 15:07
 */
public class Demo1 {
    public static void main(String[] args) throws SQLException {
        AddressListDao addressListDao = new AddressListDaoImpl();

        PageInfo<AddressList> pageInfo = new PageInfo<>();
        pageInfo.setPageIndex(1);
        pageInfo.setPageSize(5);

        AddressList addressListCondition = new AddressList();
        addressListCondition.setAddName("张");
        addressListCondition.setAddPhone("144");

        pageInfo = addressListDao.listPage(pageInfo,addressListCondition);

        System.out.println("pageInfo.getPageSize() = " + pageInfo.getPageSize());
        System.out.println("pageInfo.getCount() = " + pageInfo.getCount());
        System.out.println("pageInfo.getPageIndex() = " + pageInfo.getPageIndex());
        System.out.println("pageInfo.getTotalPages() = " + pageInfo.getTotalPages());

        pageInfo.getPageList().forEach( addressList -> System.out.println(addressList.getAddName()));

        DatabaseUtil.closeConnection();

    }
}
